//
// Created by ZYZ on 2020/6/16.
//

#include <stdio.h>
#include <stdlib.h>
#include "log.h"

//#define BUFFSIZE 512
//char buf[BUFFSIZE];

//将字符串格式化并返回    这个方法返回的 buf 是乱码？格式是 %c 则第一个字符就是乱码
//const char * sprint(const char * str,const char * content){
//    static char buf[BUFFSIZE];
//    memset(buf,0,sizeof(buf)/sizeof(char));
//    snprintf(buf, BUFFSIZE, str,content); //snprintf() 比 sprintf() 更安全，不会溢出，超过 BUFFSIZE 的会被截断
//    return buf;
//}

void print(const char *content) {
    printf("%s", content);
}

void print(const char *content, FORE_COLOR foreColor) {
    printf("\033[%dm%s\033[0m", foreColor, content);
}

void print(const char *content, FORE_COLOR foreColor, BACK_COLOR backColor) {
    printf("\033[%d;%dm%s\033[0m", backColor, foreColor, content);
}


void Log::i(const char *content) {
    print(content, FORE_WHITE);
}

void Log::d(const char *content) {
    print(content, FORE_YELLOW);
}

void Log::w(const char *content) {
    print(content, FORE_PINKISH);
}

void Log::e(const char *content) {
    print(content, FORE_RED);
}